package videoCourse.Structure;

public class MyQueue {

    int[] elements = new int[0];

    //入队
    public void add(int num){
        int[] newArray = new int[elements.length+1];
        for(int i =0;i<elements.length;i++){
             newArray[i] = elements[i];
        }
        newArray[elements.length] = num;
        elements = newArray;
    }
    //出队
    public int poll(){
        int target = elements[0];
        int[] newArray = new int[elements.length-1];
        for(int i = 0;i<elements.length-1;i++){
            newArray[i] = elements[i+1];
        }
        elements = newArray;
        return target;
    }
    //判断队列是否为空
    public boolean isEmpty(){
        return elements.length==0;
    }
}
